package top.humbleyuan.linkedlist;

import top.humbleyuan.datastructure.linkedlist.LinkNode;

/**
 * @Author HumbleYuan
 * @Date 2020/5/18 22:34
 * @Des 移除链表元素
 */
public class LeetCode_203 {
    public static void main(String[] args) {
        /**
         * 数据准备
         */
        LinkNode head = new LinkNode(3);
        int[] vals = {};
        head = LinkNode.formLink(head,vals);
        int val = 3;

        LinkNode root = new LinkNode(0);
        root.next = head;

        LinkNode temp = root;

        while (temp != null && temp.next != null) {
            if(temp.next.val == val) {
                temp.next = temp.next.next;
                if(temp.next != null && temp.next.val == val)
                    continue;
            }
            temp = temp.next;
        }

        LinkNode.headToString(root.next);
    }
}
